<!DOCTYPE html>
<title>test</title>

<ul class=tabs>
	<li>one</li>
	<li>two</li>
	<li class=current>three</li>
	<li>four</li>
</ul>
<div class=cards>
	<div>I am the content connected to the first tab.</div>
	<div>I am the content connected to the second tab.</div>
	<div class=current>I am the content connected to the third tab.</div>
	<div>I am the content connected to the fourth tab.</div>
</div>
<style>
.tabs {
	display: -moz-box;
	display: -webkit-box;
	display: -webkit-flexbox;
	display: flexbox;
	padding: 0 0 0 2px;
	margin: 1em 0 0;
}
.tabs > li {
	display: block;
	background: white;
	color: gray;
	padding: 2px 5px 0;
	margin: 0 1px;
	border-radius: .5em .5em 0 0;
	border: 2px solid;
	border-bottom: none;
	cursor: pointer;
}
.tabs > li.current {
	color: black;
	border-bottom: 2px solid transparent;
	position: relative;
	bottom: -2px;
	-moz-box-ordinal-group: 0;
	-webkit-box-ordinal-group: 0;
	-webkit-flex-order: -1;
	flex-order: -1;
}
.cards {
	border: 2px solid;
	width: 500px;
}
.cards > * {
	min-height: 50px;
	padding: 1em;
}
.cards > :not(.current) {
	display: none;
}
</style>
<script>
function find(sel) { return document.querySelector(sel); }
function findAll(sel) { return [].slice.call(document.querySelectorAll(sel)); }

var tabs = findAll('.tabs > *');
var cards = findAll('.cards > *');
tabs.forEach(function(el) {
	el.onclick = function(e) {
		findAll('.current').forEach(function(el) { el.classList.remove('current'); });
		el.classList.add('current');
		var index = tabs.indexOf(el);
		cards[index].classList.add('current');
	};
});
</script>